<?php
header("Pragma: public");
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-word");
header('Content-Disposition: attachment; filename=fislist.doc');
header("Content-Transfer-Encoding: binary"); 


foreach ($abiturients as $abiturient):
	echo '<table width="100%" border="1" cellspacing="2" cellpadding="2">';
	echo '<tr>';
	echo '<td>Номер заявления ОУ</td>';
	echo '<td>'.$abiturient['Abiturient']['id'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Дата регистрации</td>';
	echo '<td>'.$abiturient['Abiturient']['created'].'</td>';
	echo '</tr>';

	if (!empty($abiturient['Abiturient']['canceleddate'])) {
		echo '<tr>';
		echo '<td>Дата Выдачи документов</td>';
		echo '<td>'.$abiturient['Abiturient']['canceleddate'].'</td>';
		echo '</tr>';
	}

	
	echo '<tr>';
	echo '<td>Гражданство</td>';
	echo '<td>'.$abiturient['Citizenship']['name'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Серия паспорта</td>';
	echo '<td>'.$abiturient['Abiturient']['passport_ser'].'</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Номер паспорта</td>';
	echo '<td>'.$abiturient['Abiturient']['passport_num'].'</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Фамилия</td>';
	echo '<td>'.$abiturient['Abiturient']['lastname'].'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td>Имя</td>';
	echo '<td>'.$abiturient['Abiturient']['firstname'].'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td>Отчество</td>';
	echo '<td>'.$abiturient['Abiturient']['surname'].'</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Дата выдачи паспорта</td>';
	echo '<td>'.$abiturient['Abiturient']['passport_issuedate'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Кем выдан</td>';
	echo '<td>'.$abiturient['Abiturient']['passport_data'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Код подразделения</td>';
	echo '<td>'.$abiturient['Abiturient']['passport_code'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Дата Рождения</td>';
	echo '<td>'.$abiturient['Abiturient']['birthdate'].'</td>';
	echo '</tr>';
	
	$selectedprofessions = $abiturient['Selectedprofession'];
	
	foreach ($selectedprofessions as $selectedprofession):
	echo '<tr>';
	echo '<td>Выбранная специальность</td>';
	echo '<td>'.$professions[$selectedprofession['profession_id']].' '.$learningforms[$selectedprofession['learningform_id']].' '.$learningtypes[$selectedprofession['learningtype_id']].'</td>';
	echo '</tr>';	
	endforeach;
	
	$results = $abiturient['Result'];
	
	foreach ($results as $result):
	echo '<tr>';
	echo '<td>Оценка по <b>'.$subjects[$result['subject_id']].'</b></td>';
	echo '<td>'.$resulttypes[$result['resulttype_id']].' '.$result['score'].'</td>';
	echo '</tr>';	
	endforeach;
	
	echo '<tr>';
	echo '<td>Тип документа об  образовании</td>';
	echo '<td>'.$educationdoctypes[$abiturient['Abiturient']['educationdoctype_id']].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Данные документа об  образовании</td>';
	echo '<td>'.$abiturient['Abiturient']['educationdocdata'].'</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '<td>Оригинал документа об  образовании</td>';
	if ($abiturient['Abiturient']['originaleducationdoc']){
		echo '<td>ДА</td>';
	} else {
		echo '<td>НЕТ</td>';
	}
	echo '</tr>';
	
	if (!empty($abiturient['Targetingintake'])) {
		echo '<tr>';
		echo '<td>Целевое направление - организация</td>';
		echo '<td>'.$tgintakeorgs[$abiturient['Targetingintake'][0]['tgintakeorg_id']].'</td>';
		echo '</tr>';		
		
		echo '<tr>';
		echo '<td>Направление куда</td>';
		echo '<td>'.$professions[$abiturient['Targetingintake'][0]['profession_id']].' '.$learningforms[$abiturient['Targetingintake'][0]['learningform_id']].' '.$learningtypes[$abiturient['Targetingintake'][0]['learningtype_id']].'</td>';
		echo '</tr>';
	}
	
	
	if (!empty($abiturient['Privilege'])) {
		echo '<tr>';
		echo '<td>ЛЬгота</td>';
		echo '<td>'.$abiturient['Privilege'][0]['name'].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Серия док-та ЛЬготы</td>';
		echo '<td>'.$abiturient['Privilegedoc'][0]['doc_ser'].'</td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>Номер док-та ЛЬготы</td>';
		echo '<td>'.$abiturient['Privilegedoc'][0]['doc_num'].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Когда выдана</td>';
		echo '<td>'.$abiturient['Privilegedoc'][0]['issuedate'].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Кем выдана</td>';
		echo '<td>'.$abiturient['Privilegedoc'][0]['data'].'</td>';
		echo '</tr>';
		
		
	}
	
	
	if (!empty($abiturient['Enrolledstudent'])) {
		echo '<tr>';
		echo '<td>Зачислен</td>';
		echo '<td>'.$professions[$abiturient['Enrolledstudent'][0]['profession_id']].' '.$learningforms[$abiturient['Enrolledstudent'][0]['learningform_id']].' '.$learningtypes[$abiturient['Enrolledstudent'][0]['learningtype_id']].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Номер приказа</td>';
		echo '<td>'.$abiturient['Enrolledstudent'][0]['order_number'].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Дата приказа</td>';
		echo '<td>'.$abiturient['Enrolledstudent'][0]['order_date'].'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td>Волна зачисления</td>';
		echo '<td>'.$abiturient['Enrolledstudent'][0]['wave_id'].' волна</td>';
		echo '</tr>';
		

		echo '<tr>';
		echo '<td>Основание</td>';
		echo '<td>';
		switch ($abiturient['Enrolledstudent'][0]['status']){
			case 1: echo 'льготник';
			break;
			case 2: echo 'целевик';
			break;
			case 3: echo 'общий рейтинг';
			break;
		}
		echo '</td>';
		echo '</tr>';
	}

	
	
	echo '</table>';
	echo '<br>';
	echo '<hr>';
	echo '<br>';	
	//die();
endforeach;
?>

